package com.anjiplus.template.gaea.business.work.station.dao;

import com.anjiplus.template.gaea.business.work.station.entity.Station;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author yxm
 */
@Mapper
public interface StationDao {

    /**
     * 查询全部站点列表
     *
     * @return
     */
    @Select("select * from t_station where deleted = 0")
    List<Station> listAll();

    /**
     * 根据站点名称模糊查询站点列表
     *
     * @param name
     * @return
     */
    @Select("select * from t_station where name like concat('%', #{name}, '%') and deleted = 0")
    List<Station> listByStationName(String name);

    /**
     * 添加站点
     *
     * @param station
     * @return
     */
    @Insert("insert into t_station(id,code,name,deleted) values(uuid(),#{code},#{name},0)")
    int add(Station station);

    /**
     * 移除站点
     *
     * @param id
     * @return
     */
    @Delete("update t_station set deleted=1 where id=#{id}")
    int remove(String id);

    /**
     * 修改站点
     *
     * @param station
     * @return
     */
    @Update("update t_station set code=#{code},name=#{name} where id=#{id}")
    int update(Station station);

}
